package didi.hcp.idempotent.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import didi.hcp.idempotent.entity.User;
import didi.hcp.idempotent.entity.UserBo;
import didi.hcp.idempotent.mapper.UserMapper;
import didi.hcp.idempotent.service.IUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**                                                                                ____________________
      _                _                                                           < 神兽护体，永无bug! >
    | |__  _   _  ___| |__   ___ _ __   __ _ _ __   ___ _ __   __ _                --------------------
   | '_ \| | | |/ __| '_ \ / _ \ '_ \ / _` | '_ \ / _ \ '_ \ / _` |                       \   ^__^
  | | | | |_| | (__| | | |  __/ | | | (_| | |_) |  __/ | | | (_| |                        \  (oo)\_______
 |_| |_|\__,_|\___|_| |_|\___|_| |_|\__, | .__/ \___|_| |_|\__, |                           (__)\       )\/\
                                   |___/|_|                |___/                                ||----w |
                                                                                                ||     ||
 * @author huchengpeng
 * @date 2021/8/16 23:20
 * @version 1.0.0
 * @Description 用户服务实现类
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> getUserList() {
        return userMapper.selectList(null);
    }

    @Override
    public void updateUser(UserBo userBo) {
        User user = new User();
        BeanUtils.copyProperties(userBo,user);
        userMapper.updateUser(user);
    }

    @Override
    public int insertUser(UserBo userBo) {
        User user = new User();
        BeanUtils.copyProperties(userBo,user);
        userMapper.insertUser(user);
        return 0;
    }
}
